from appium import webdriver
from time import sleep
import random

from appium.webdriver.common.touch_action import TouchAction

desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = 'moniqi'
# 设置
# desired_caps['appPackage'] = 'com.android.settings'
# desired_caps['appActivity'] = '.Settings'
# 手势密码
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.ChooseLockPattern'
# 通讯录
# desired_caps['appPackage'] = 'com.android.contacts'
# desired_caps['appActivity'] = '.activities.PeopleActivity'
# 文件管理
# desired_caps['appPackage'] = 'com.cyanogenmod.filemanager'
# desired_caps['appActivity'] = '.activities.NavigationActivity'
# 输入中文
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

TouchAction(driver).press(x=120, y=420).move_to(x=360, y=660).move_to(x=120, y=900).move_to(x=600, y=420).move_to(x=120,
                                                                                                                  y=660).move_to(
    x=600, y=900).move_to(x=360, y=420).move_to(x=360, y=900).move_to(x=600, y=660).release().perform()

sleep(3)
driver.quit()
